package andrei.mower2.utils;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.SortedSet;

import andrei.mower2.business.MowerDriveResult;
import andrei.mower2.business.output.MowerDriveResultOutputter;
import andrei.mower2.io.file.MowerFileInputReader;

public class MockUtils {

	public static MowerFileInputReader getMowerStringInputReader(String fileContent) throws IOException {
		ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(fileContent.getBytes());
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(byteArrayInputStream));
		return new MowerFileInputReader(bufferedReader);
	}
	
	public static MowerDriveResultOutputter getStringResultOutputter(final SortedSet<String> outputLines) {
		return new MowerDriveResultOutputter() {
			
			@Override
			public void output(MowerDriveResult result) {
				outputLines.add(result.toOutputString());
			}
			
			@Override
			public void close() {}
		};
	}
}
